package wibrst.visual.dialog {
	import flash.display.SimpleButton;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
	import flash.text.TextField;
	import flash.ui.Keyboard;
	import flash.utils.Timer;
	import wibrst.style.StyleLib;
	
	/**
	 * ...
	 * @author wibrst@qq.com
	 */
	public class VPromptBase extends VPromptPure {
	
		static public const EVT_OK:String = "EVT_OK";
		static public const EVT_CLOSE:String = "EVT_CLOSE";
		
		public function VPromptBase() {
			this.txPrompt.multiline = true;
			this.txPrompt.embedFonts = false;
			this.txPrompt.styleSheet = StyleLib.sole.cssPromptText;
			this.btnOK.addEventListener( MouseEvent.CLICK, btnOKHandler );
			//setAutoCloseDur( 3000 );
			super.addEventListener( Event.ADDED_TO_STAGE , this.addedStageHandler );
		}
		
		private function addedStageHandler(e:Event):void {
			super.removeEventListener(Event.ADDED_TO_STAGE, this.addedStageHandler);
			if ( stage ) stage.addEventListener(KeyboardEvent.KEY_UP, keyHandler );
		}
		
		private function keyHandler( evt:KeyboardEvent ):void {
			if ( evt.keyCode == Keyboard.ENTER ) {
				super.dispatchEvent( new Event( EVT_OK ) );
			}
		}
		
		public function setPrompt( sCont:String ):void {
			this.txPrompt.htmlText = sCont;
		}
		
		private function btnOKHandler( evt:MouseEvent ):void {
			super.dispatchEvent( new Event( EVT_OK ) );
		}
		
		/// pre-layed
		public var txPrompt:TextField;
		public var btnOK:SimpleButton;
		
	}

}